<?php

function member_offer_info_page($oid){
    return member_get_offer_info_format(member_get_offer_info($oid));
}

function member_get_offer_info($oid){

        $query = db_select('ep_offers','o');
        $query->join('ep_restaurants', 'r', 'o.rid = r.rid');
        $query->fields('o', array('oid','offer','price','startdate','enddate','rid'))
                    ->fields('r',array('name','rid','city','website','telephone','open','delivery','wifi','parking'));

        $query -> condition('oid',$oid,'=');
        $results = $query
                    ->execute();
        $infos = array();	
        foreach ($results as $info) {
	$infos = 
			 array(
                            'name'=>$info->name,
                            'offer'=>$info->offer,
                            'price'=>$info->price,
                            'startdate'=>$info->startdate,
                            'city'=>$info->city,
                            'website'=>$info->website,
                            'telephone'=>$info->telephone,
                            'open'=>$info->open,
                            'delivery'=>$info->delivery,
                            'wifi'=>$info->parking

        );
        }       
        return $infos;
    }

function member_get_offer_info_format($infos){
    return
    "<h2>Ajánlat információ:</h2>".
    '<table border="0">'.
    "<tr><td><strong>Étterem neve:</strong</td>"."<td>".$infos['name']."</d></tr>".
    "<tr><td><strong>Ajánlat:</strong</td>"."<td>".$infos['offer']."</d></tr>".
    "<tr><td><strong>Ár:</strong</td>"."<td>".$infos['price']." Ft"."</d></tr>".
    "<tr><td><strong>Ajánlat napja:</strong</td>"."<td>".$infos['startdate']."</td></tr>".
    "<tr><td colspan='2'><strong>Érdeklődni:</strong>
    <p>A ".$infos['telephone']." telefon számon vagy a ".$infos['website']." oldalon. Nyitva: ".$infos['open']."</p></td>
    </tr>".
    '</table>';
} 